package com.activities.api.data.server;

import java.util.Collection;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.activities.api.data.entities.User;
import com.activities.api.data.providers.UserStore;
import com.google.inject.Inject;

@Path("/userservice")
public class UserServiceImpl extends ServiceImpl<User> implements UserService {
	
	@Inject
	private UserStore store;

	public UserStore getStore() {
		return store;
	}

	public void setStore(UserStore store) {
		this.store = store;
	}

	@GET
	@Path("/users/{id}")
	@Produces("application/xml")
	@Override
	public User get(@PathParam("id") String id) {
		UserStore store = getStore();

		return store.get(id);
	}

	@GET
	@Path("/users/")
	@Produces("application/xml")
	@Override
	public Collection<User> getAll() {
		UserStore store = getStore();

		return store.getAll();
	}

	@POST
	@Path("/users/")
	@Consumes("application/xml")
	@Override
	public void save(User user) {
		UserStore store = getStore();

		store.save(user);
	}

	@DELETE
	@Path("/users/{id}")
	@Override
	public void delete(@PathParam("id") String id) {
		UserStore store = getStore();

		store.delete(id);
	}
}
